package leetcode.code0566;

import leetcode.IDebug;

public class Solution implements IDebug {

	public int[][] matrixReshape(int[][] mat, int r, int c) {
		int m = mat.length, n = mat[0].length;
		if (m * n != r * c) {
			return mat;
		}
		int[][] ans = new int[r][c];
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n; j++) {
				int cur = mat[i][j];
				int idx = i * n + j;
				ans[idx / c][idx % c] = cur;
			}
		}
		return ans;
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
